package com.onix.actions;

import java.io.IOException;
import java.io.InputStream;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.view.Window;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

public class EtwasAdapter {
	static final int REQUEST_ABOUT = 0;
	static final int REQUEST_CAREERS = 1;
	static final int REQUEST_CLIENTS = 2;
	static final int REQUEST_CONTACTS = 3;
	static final int REQUEST_SERVICES = 4;
	
	private final Context outerContext;
	private InputStream tempInputStream;

	public EtwasAdapter(Context ctx) {
		outerContext = ctx;
	}

	public boolean selectMenu(int item) {
		switch (item) {
		case R.id.menu_about:
		case R.id.menu_careers:
		case R.id.menu_clients:
		case R.id.menu_contacts:
		case R.id.menu_services:
			Intent intentInformation = new Intent(outerContext, PageInformation.class);
			intentInformation.putExtra("page", item);
			outerContext.startActivity(intentInformation);
			return true;
		}
		return false;

	}
	
	public void makePage(ImageView outerMenuImage,
			int outerMenuImageR, TextView outerContentTitle,
			int outerContentTitleR, WebView outerWebView, String outerHTMLText) {
		outerMenuImage.setImageDrawable(outerContext.getResources()
				.getDrawable(outerMenuImageR));
		outerContentTitle.setText(outerContext.getResources().getString(
				outerContentTitleR));

		try {
			tempInputStream = outerContext.getAssets().open(outerHTMLText);
			int size = tempInputStream.available();
			byte[] buffer = new byte[size];
			tempInputStream.read(buffer);
			tempInputStream.close();
			String text = new String(buffer);
			outerWebView.loadData(text, "text/html", "utf-8");
			outerWebView.setBackgroundColor(0);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}

	}

}
